package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.CountryAreaCodeVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.CountryAreaCodeNameVO;
import com.ssy.lingxi.member.merchant.service.base.IBaseCountryAreaService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu Web/App通用 - 省市区相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-05-12
 */
@RestController
@RequestMapping("/member/area")
public class CountryAreaController {
    @Resource
    private IBaseCountryAreaService baseCountryAreaService;

    /**
     * 注册页面 - 查询省列表
     * @return 查询结果
     */
    @RequestMapping(value = "/province", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> listProvince() {
        return baseCountryAreaService.listProvince();
    }

    /**
     * 注册页面 - 根据省编码，查询市列表
     * @param codeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/city", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> listCitiesByProvinceCode(@Valid CountryAreaCodeVO codeVO) {
        return baseCountryAreaService.listCitiesByProvinceCode(codeVO);
    }


    /**
     * 注册页面 - 根据市编码，查询区列表
     * @param codeVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/district", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> listDistrictsByCityCode(@Valid CountryAreaCodeVO codeVO) {
        return baseCountryAreaService.listDistrictsByCityCode(codeVO);
    }
}
